package com.woniuxy.woniubookmanager.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniuxy.woniubookmanager.result.ResponseResult;
import com.woniuxy.woniubookmanager.service.OrderService;
import com.woniuxy.woniubookmanager.vo.OrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wugd
 * @since 2022-11-29 04:03:13
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    OrderService orderService ;

    @GetMapping("/list")
    public ResponseResult<Page<OrderVo>> list(@RequestParam(value = "now",defaultValue = "1") Integer now,
                                              @RequestParam(value = "size",defaultValue = "2") Integer size,
                                              String orderNum){
        ResponseResult<Page<OrderVo>> result  = null;
        try {
            Page<OrderVo> page = orderService.getOrderByPage(now,size,orderNum);
            result = new ResponseResult<>(200,"ok",page);
        }catch (RuntimeException e){
            e.printStackTrace();
            result = new ResponseResult<>(201,"查询失败!");
        }
        return result ;
    }
}

